package com.isometricProjectionExmaple
{
	import flash.geom.Point;

	/**处理世界坐标和屏幕坐标之间的转换**/
	public class IsoUtils
	{
		public function IsoUtils()
		{
			
		}
		
		public static const Y_CORRECT:Number = Math.cos(-Math.PI /6)*Math.SQRT2;
		
		/**3d坐标转2d屏幕坐标**/
		public static function isoToScreen(pos:Point3D):Point
		{
			var screenX:Number = pos.x - pos.z;
			var screenY:Number = pos.y * Y_CORRECT + (pos.x +　pos.z) * 0.5;
			return new Point(screenX,screenY);
		}
		
		/**2d坐标转3d坐标**/
		public static function screenToIso(point:Point):Point3D
		{
			var xpos:Number = point.y +point.x *0.5;
			var ypos:Number = 0;
			var zpos:Number = point.y - point.x *0.5;
			return new Point3D(xpos,ypos,zpos);
		}
	}
}